package tsing.javase.thread;

import java.util.Map;

/**
 * Thread的join方法
 */
public class Join {
    static class ThreadA implements Runnable {

        @Override
        public void run() {
            try {
                System.out.println("我是子线程，我先睡一秒");
                Thread.sleep(5000);
                System.out.println("我是子线程，我睡完了一秒:\t"+System.currentTimeMillis());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new ThreadA());
        System.out.println(System.currentTimeMillis());
        thread.start();
        thread.join(1000);
        System.out.println(thread.getName()+"\t:\t"+thread.getState());
        System.out.println("如果不加join方法，我会先被打出来，加了就不一样了,:\t"+System.currentTimeMillis());


    }
}
